/**
 * This file is part of AppStoreBot.
 *
 *  AppStoreBot is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AppStoreBot is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AppStoreBot.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
package lu.pragmaconsult.appstorebot.itunes;

import java.util.Scanner;

import lu.pragmaconsult.appstorebot.BotContext;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;

/**
 * TODO: Type comment
 * @author Wilfried Vandenberghe (wilfried.vandenberghe at pragmaconsult.lu)
 */
class PasswordFromInputBotState extends AbstractBotState {
	
	@Override
	protected HttpMethod createHttpMethod(BotContext context, HttpClient httpClient) {
		return null;
	}
	
	@Override
	protected void processResponseBody(BotContext context, HttpMethod method) {
		System.out.print("Password: ");
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			
			context.setPassword(scanner.nextLine());
			
			System.out.println();
		} finally {
			if(scanner != null) {
				try { 
					scanner.close(); 
				} catch(IllegalStateException e) {}
			}
		}
	}
	
	@Override
	protected BotState getNextState() {
		return new ConnectBotState();
	}

}
